<?php

namespace App\Models\Issue;

use App\Models\Groupable;
use App\Support\Database\Eloquent\UuidModel;

class Issue extends UuidModel
{
    use Groupable;

    const TYPE_QUIZ = 1;
    const TYPE_VOTE = 2;

    const ALLOW_TYPES = [
        self::TYPE_QUIZ => '竞猜',
        self::TYPE_VOTE => '投票',
    ];

    protected $fillable = [
        'type',
        'group_code',
        'title',
        'description',
        'configuration',
    ];

    protected $casts = [
        'configuration' => 'json',
    ];

    public function options()
    {
        return $this->hasMany(IssueOption::class, 'issue_id', 'id');
    }
}
